<template>
  <h2 class="mb-3 font-bold text-center enter-x xl:text-left" style="font-size: 1rem; color: #fff">
    <!-- {{ getAppFullTitle }} -- {{ getFormOperateTitle }} -->
    {{ getAppFullTitle }}
  </h2>
</template>
<script lang="ts" setup>
  import { computed, unref } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { LoginStateEnum, useLoginState } from './useLogin';
  import { useGlobSetting } from '/@/hooks/setting';
  import { useUserStore } from '/@/store/modules/user';

  const { t } = useI18n();

  const { getLoginState } = useLoginState();
  const userStore = useUserStore();
  const { title } = useGlobSetting();

  /**
   * 获取APP完整标题文字
   */
  const getAppFullTitle = computed(() => {
    let fullTitle = title;
    const currentProject = userStore.getUserCurrentProject;
    if (currentProject != undefined && currentProject != null) {
      //取store中当前项目信息的values，按对象方式取值
      if (currentProject.values != undefined && currentProject.values != null) {
        let fullTitleValue = currentProject.values.fullTitle;
        // fullTitleValue = currentProject.values["fullTitle"];
        if (fullTitleValue != undefined && fullTitleValue != null && fullTitleValue != '')
          fullTitle = fullTitleValue;
      }
    }
    return fullTitle;
  });

  /**
   * 获取APP完整标题文字
   */
  const getAppTitle = computed(() => {
    let appTitle = title;
    const currentProject = userStore.getUserCurrentProject;
    if (currentProject != undefined && currentProject != null) {
      //取store中当前项目信息的values，按对象方式取值
      if (currentProject.values != undefined && currentProject.values != null) {
        let appTitleValue = currentProject.values.appTitle;
        // appTitleValue = currentProject.values["appTitle"];
        if (appTitleValue != undefined && appTitleValue != null && appTitleValue != '')
          appTitle = appTitleValue;
      }
    }
    return appTitle;
  });

  /**
   * 获取窗口的操作标题--对应的操作是登录、注册还是重置密码等
   */
  const getFormOperateTitle = computed(() => {
    const titleObj = {
      [LoginStateEnum.RESET_PASSWORD]: t('sys.login.forgetFormTitle'),
      [LoginStateEnum.LOGIN]: t('sys.login.signInFormTitle'),
      [LoginStateEnum.REGISTER]: t('sys.login.signUpFormTitle'),
      [LoginStateEnum.MOBILE]: t('sys.login.mobileSignInFormTitle'),
      [LoginStateEnum.QR_CODE]: t('sys.login.qrSignInFormTitle'),
    };
    return titleObj[unref(getLoginState)];
  });
</script>
